//Remix of D Sutherland program with banana, cereal and text

int tx, ty, bx, by;
PFont f; 

//a function to set up the general drawing parameters
void setup() {
  size(400,400);
  background(#000000);
  smooth();
  tx = 400;
  ty = 100;
  bx = 340;
  by = 300;
  frameRate(20);
  f = createFont("Arial",16,true); // STEP 3 Create Font
}

//press any key to reset the fish
void keyPressed() {
  tx = 400;
  ty = 100;
  bx = 340;
  by = 300;
}

//function to draw the fish
void drawSpoonguy() {
  //person code
  ellipse(50,200,50,50);
  line(45,375,45,320);
  line(55,370,55,320);
  line(55,370,65,370);
  line(45,375,55,375);
  ellipse(40,190,20,20);
  ellipse(65,190,20,20);
  ellipse(35,190,2,2);
  ellipse(70,190,2,2);
  arc(45,210,30,10,65,210);
  line(60,250,90,230);
  ellipse(50,275,40,100);
  line(60,260,90,250);
  //spoon
  ellipse(90,250,5,150);
  ellipse(90,150,50,70);
}

void drawB() {
  
  fill(#D3D315);
  //body
  arc(0, 0, 55, 92, 1.5*PI-.3, 2.5*PI+.3);
  fill(255);
  arc(-11, 0, 45, 80, 1.5*PI, 2.5*PI);
  //eyes
  ellipse(10, -10, 20, 20);
  ellipse(25, -10, 20, 20);
  //mouth
  arc(15, 10, 20, 10, PI, 2*PI);
  //pupils
  fill(0);
  ellipse(10, -10, 2, 2);
  ellipse(25, -10, 2, 2);
  //legs
  line(0, 45, -3, 65);
  line(5, 42, 5, 67);
  line( -3, 65, -8, 65);
  line(5, 67, 0, 67);
  fill(255);
  //arms
  arc(-2, 30, 16, 10, PI-.4, 2*PI-.2);
  arc(28, 32, 16, 8, PI-.4, 2*PI-.2);
  
}

  

//the draw function - which will loop
void draw() {
  
  background(#FFFFFF);
  
  //cereal bowl
  strokeWeight(1.5);
  ellipse(150, 370, 10, 10);
  ellipse(145, 372, 8, 10);
  ellipse(153, 369, 10, 9);
  arc(150, 370, 30, 30, 0, PI);
  line(135, 370, 165, 370);
  
  pushMatrix();
    translate( tx, ty);
    drawSpoonguy();
  popMatrix();
    
  pushMatrix();
    translate( bx, by);
    drawB();
  popMatrix();
   
  
  if (tx > 30) {
    //update my variables - either randomly update y or use sin
    tx = tx - 1;
    ty = 5 + int(20*sin(tx/400.0*6*PI));
  } else {
      fill(0);
      textFont(f,16);    
      text("My spoon is too big!!",150,150); 
      fill(255);
  }
  
  bx = bx + int(random(-2, 2));
  by = by + int(random(-2, 2));
}